Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Slight refactor to collection widening #30076

Merged
merged 7 commits into from
Dec 1, 2018
Merged

Slight refactor to collection widening #30076

merged 7 commits into from
Dec 1, 2018

Conversation

bramtayl
Copy link
Contributor

Pull out specifically collection widening to its own functions. This will allow overloading these functions for data-structures which are easier to widen than Arrays, e.g. ModelArrays (see #13942)
The eltype checks seem redundant but help make the functions more generalizable. I think they're costless anyway.

Copy link
Member

@vtjnash vtjnash left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might need an explicit inline annotation, since part of the existing trick is that this elides dispatch by moving all of the dynamic cost into one branch

@bramtayl
Copy link
Contributor Author

Ok

@bramtayl
Copy link
Contributor Author

Wait, I'm confused.... adding the @inline annotations made CI fail? Did I make a typo or something?

@martinholters
Copy link
Member

IIRC, @inline is not defined when array.jl is read during bootstrap. Try @_inline_meta (inside the function body) instead.

@bramtayl
Copy link
Contributor Author

Oh ok

@bramtayl
Copy link
Contributor Author

Well it looks like this is passing. Is it worth running benchmarks?

@andyferris
Copy link
Member

I like this.

I hope this pattern will be easier to replicate in custom array code and custom operations on containers. Currently I find implementing a “widening” approach instead of a “inference” approach to container allocation quite tiresome, but I think this could help immensely.

base/array.jl Outdated Show resolved Hide resolved
base/array.jl Outdated Show resolved Hide resolved
base/array.jl Outdated Show resolved Hide resolved
base/array.jl Outdated Show resolved Hide resolved
base/array.jl Outdated Show resolved Hide resolved
base/array.jl Outdated Show resolved Hide resolved
@bramtayl
Copy link
Contributor Author

Ok I think I've addressed all the comments

@bramtayl
Copy link
Contributor Author

Good?

Copy link
Member

@andyferris andyferris left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks both sound and useful.

@andyferris andyferris merged commit 5b827f5 into JuliaLang:master Dec 1, 2018
@bramtayl bramtayl mentioned this pull request Dec 10, 2018
@bramtayl
Copy link
Contributor Author

Is this backsportable?

@fredrikekre
Copy link
Member

No, its not a bugfix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants